package com.qlslylq.ad.sdk.model.rsp;

import com.qlslylq.ad.sdk.enums.ErrorEnum;
import com.qlslylq.ad.sdk.net.ResponseObject;

/**
 * 包装特定网络异常到响应结果中,方便从响应中看出错误<br/>
 */
public class ErrorResponse {

    /**
     * 客户端网络没有开启
     */
    public static ResponseObject errorConnectResponse() {
        ResponseObject response = new ResponseObject();
        response.setCode(ErrorEnum.ERR_CONN.getId());
        response.setMessage(ErrorEnum.ERR_CONN.getName());
        return response;
    }

    /**
     * 连接超时
     */
    public static ResponseObject errorConnectTimeoutResponse() {
        ResponseObject response = new ResponseObject();
        response.setCode(ErrorEnum.ERR_CONN_TIME_OUT.getId());
        response.setMessage(ErrorEnum.ERR_CONN_TIME_OUT.getName());
        return response;
    }

    /**
     * 响应超时
     */
    public static ResponseObject errorSocketTimeoutResponse() {
        ResponseObject response = new ResponseObject();
        response.setCode(ErrorEnum.ERR_SOCKET_TIME_OUT.getId());
        response.setMessage(ErrorEnum.ERR_SOCKET_TIME_OUT.getName());
        return response;
    }

    /**
     * 数据解析错误
     */
    public static ResponseObject errorJsonDataResponse() {
        ResponseObject response = new ResponseObject();
        response.setCode(ErrorEnum.ERR_JSON_SYNTAX.getId());
        response.setMessage(ErrorEnum.ERR_JSON_SYNTAX.getName());
        return response;
    }

    /**
     * 其它类型网络异常
     */
    public static ResponseObject errorNetOtherResponse() {
        ResponseObject response = new ResponseObject();
        response.setCode(ErrorEnum.ERR_NET_OTHER.getId());
        response.setMessage(ErrorEnum.ERR_NET_OTHER.getName());
        return response;
    }

}
